package Homework.Top01.Test;

import java.util.IllegalFormatCodePointException;

public class Shopping {
    String name;//商店名称
    String address;//商店地址
    int pos;//人数
    Vip[] vips=new Vip[100];

    public boolean addvip(Vip vip){
        if (pos>vips.length){
            System.out.println("本店会员数量已达上线");
            return false;
        }
        for (int i=0;i<pos;i++){
            if (vips[i].vipNum.equals(vip.vipNum)){
                System.out.println("不能重复添加同一会员");
                return false;
            }
        }
        vips[pos++]=vip;
        return true;
    }



    public void printInfo(){
        System.out.println("商店："+name+" 地址："+address);
        System.out.println("会员号\t会员姓名\t会员手机\t会员积分");
        for (Vip v:vips){
            if (v==null){
                break;
            }
            System.out.println(v.vipNum+"\t\t"+v.vipName+"\t\t"+v.phone+"\t\t"+v.integral);
        }
    }

    /*public String duihuan(String cardNo,int lipingleixing){
        System.out.println("请输入需要兑换的礼品：");
        System.out.println("1：100分兑换餐巾纸一包；\n" +
                "     2：400分兑换剃须刀一把；\n" +
                "     3：1000分兑换炒锅一个；");
        int leixing;

    }*/

    public boolean inc(String vipnum,int integral){
        for (int i = 0;i<pos;i++){
            if (vips[i].vipNum.equals(vipnum)){
                vips[i].integral+=integral;
                System.out.println("添加成功 本次积分："+vips[i].integral);
                return true;
            }
        }
        System.out.println("账号不存在");
        return false;
    }
    public String exchange(String vipnum,int duihuan){
        int i = 0;
        for (i = 0;i<pos;i++){
            if (vips[i].vipNum.equals(vipnum)){
                break;
            }
        }
        if (duihuan==1&&vips[i].integral>=100) {
            System.out.println("兑换到餐巾纸一包");
            vips[i].integral -= 100;
            return "兑换成功";
        }
        if (duihuan==2&&vips[i].integral>=400){
            System.out.println("兑换到剃须刀一把");
            vips[i].integral-=400;
            return "兑换成功";
        }
        if (duihuan==3&&vips[i].integral>=1000){
            System.out.println("兑换到炒锅一个");
            vips[i].integral-=1000;
            return "兑换成功";
        }
        System.out.println("会员号不正确或积分不足");
        return null;
    }
}
